package cn.cdeden.resource.unified.domain.dto;

import cn.cdeden.common.oss.enumd.OssModuleType;
import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import jakarta.servlet.http.HttpServletRequest;

/**
 * @ProjectName : ecm_svn02
 * @Package : com.cdyd.ecm.onlineedit
 * @ClassName : EditingDto
 * @Author : Yu.
 * @Description : // 编辑修改参数
 * @Date : 2023/11/14 14:45
 * @Version : 1.0
 */
@Data
@NoArgsConstructor
public class FilesEditingDto {

    /**
     * 文件名称
     **/
    private String name;

    /**
     * 文件后缀
     **/
    private String suffix;

    /**
     * 文件储存编号
     **/
    private String storageId;
    /**
     * 树编号
     **/
    private String treeId;

    private String type;
    /**
     * 编辑者编号
     **/
    private Long userId;


    /**
     * 编辑者名称
     **/
    private String username;

    /**
     * 文件库的类型
     **/
    private String fileType;

    /**
     *  文件下载地址
     **/
    private String url;


    private JSONObject info;


    public FilesEditingDto(HttpServletRequest request, String name , String suffix ) {
        this.name = name ;
        this.suffix = suffix ;
        this.storageId =  request.getParameter("id");
        this.type  = request.getParameter("type");
        this.userId = Long.valueOf(request.getParameter("userId"));
        this.username = request.getParameter("username");
        this.treeId = request.getParameter("treeId");
        this.fileType = request.getParameter("fileType");
        String info1 = request.getParameter("info");
        if(info1 != null){
            this.info = JSONObject.parseObject(info1);
        }


    }

    public FilesEditingDto(HttpServletRequest request) {
        this.storageId =  request.getParameter("id");
        this.type  = request.getParameter("type");
        this.userId = Long.valueOf(request.getParameter("userId"));
        this.username = request.getParameter("username");
        this.treeId = request.getParameter("treeId");
        this.fileType = request.getParameter("fileType");
        this.url = request.getParameter("url");
        String info1 = request.getParameter("info");
        if(info1 != null){
            this.info = JSONObject.parseObject(info1);
        }
    }

    public OssModuleType getTypeEnum() {
        return OssModuleType.findCoedInfo(this.type);
    }
}
